# @Time : 2024/7/21 17:25
# @Author : Adam
# @Version : v1.0
# @IDE : PyCharm
# @Project : tracer

class BootStrapForm(object):
    bootstrap_class_exclude = []

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            if name in self.bootstrap_class_exclude:
                continue
            old_class = field.widget.attrs.get('class', '')  # 自己定义的class
            field.widget.attrs['class'] = f'{old_class} form-control'  # 将自己定义的class添加进去
            field.widget.attrs['placeholder'] = f'请输入{field.label}'
